package cur.nature.admin.dao;

import cur.nature.admin.common.config.DBAdminConfig;
import cur.nature.admin.model.po.Admin_DeptPO;
import cur.nature.admin.model.vo.Admin_DeptVO;
import cur.nature.framework.mvc.crud.CrudDao;

import cur.nature.tinyorm.core.template.DefaultJdbcTemplate;
import cur.nature.framework.core.util.StringUtil;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.DependsOn;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 用户角色 Dao
 * 作者：Auto Generator By wujian
 * 生成日期：2023-07-10 21:42:14
 */
@Component
@DependsOn(DefaultJdbcTemplate.TEMPLATE)
public class Admin_DeptDao extends CrudDao<Admin_DeptPO, Admin_DeptVO> {
    public Admin_DeptDao(@Qualifier(DBAdminConfig.TEMPLATE) DefaultJdbcTemplate template) {
        super(Admin_DeptPO.class, Admin_DeptVO.class, template);
    }

//    public PageBean<Admin_DeptVO.Base> list(Admin_DeptVO.list_Param param) throws Exception {
//        StringBuilder condition = new StringBuilder(" 1=1 ");
////        if(StringUtil.isNotEmpty(param.getKeyword())){
////            condition.append(" and a.code like '"+param.getKeyword()+"%'");
////        }
//        String sql = "select " + this.cols() + " from " + tableName() + " a " + " where " + condition;
//        PageBean<Admin_DeptVO.Base> list = getTemplate().queryForPage(sql, param.buildPage(),
//                null, Admin_DeptVO.Base.class);
//        return list;
//    }

    public List<Admin_DeptVO> queryByCond(Admin_DeptVO.list_Param param) throws Exception {
        // 过滤条件
        final StringBuilder cond = new StringBuilder();
        if (StringUtil.isNotEmpty(param.getKeyword())) {
            cond.append(" and name like '"+param.getKeyword()+"%' ");
        }
        // 查询出所有的资源
        List<Admin_DeptVO> list = queryByCond(cond.toString());
        return list;
    }

}

